# encoding=utf-8
from datetime import datetime
from jinja2 import Environment, FileSystemLoader


def generate_html(key_value: dict):
    env = Environment(loader=FileSystemLoader('../HtmlTemplate'))
    template = env.get_template('hospital.html')
    with open("result.html", 'w', encoding="utf-8") as fout:
        html_content = template.render(**key_value)
        fout.write(html_content)


if __name__ == "__main__":
    result = {
        'patient_name': 'tacom',
        'patient_id': "20240321154555",
        'patient_sex': '男',
        'patient_age': '24',
        'patient_time': datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
        'patient_eye_right': "../SampleImage/right.png",
        'patient_eye_left': "../SampleImage/left.png",
        'patient_eye_right_analysis': "级别0, 正常",
        'patient_eye_left_analysis': "级别1， 正常",
        'patient_doctor_analysis': '正常 </br>, 建议健康生活'
    }
    generate_html(result)